<template>
	<view class="container">
		<view class="top">
			<view class="balance_con">
				<view class="balance">
					<view class="balance_title"><image mode="widthFix" :src="static+'/price.png'"></image>红积分</view>
					<view class="balance_price"><text>￥</text>{{member.balance}}</view>
				</view>
			</view>
			<view class="operate">
				<view class="used_balance">
					<view>￥{{member.withdrawable_cash_balance}}</view>
					<view>可提现</view>
				</view>
				<view class="button g" v-on:click="withdrawal">提现</view>
			</view>
			<view class="operate">
				<view class="used_balance">
					<view>{{member.blue_integral}}</view>
					<view>蓝积分</view>
				</view>
				<view class="button g" v-on:click="assignment">积分转让</view>
			</view>
		</view>
		<view class='nav'>
			<view :class='current==4?"font-color":""' class="nav_unit" id='4' v-on:click='operation'>收入</view>
			<view :class='current==5?"font-color":""' class="nav_unit" id='5' v-on:click='operation'>支出</view>
		</view>
		<view class="content" v-show="current==4">
			<view class="none" v-if="result[0].length==0">没有信息</view>
			<block  v-for="(item,index) in result[0]" :key="index" v-else>
				<view :class="item.invalid_status==1?'noneunit':'unit'">
					<view class="unit_con">
						<view class="unit_title">{{item.style}}</view>
						<view class="unit_title">{{item.u_nickname}}</view>
						<view class="unit_time" v-if="item.order_num!=null">订单编号：{{item.order_num}}</view>
						<view class="unit_time">{{item.logtime}}</view>
					</view>
					<view class="unit_property">
						<view class="price" :class="item.invalid_status==1?'f':'r'">+{{item.balance}}元</view>
					</view>
				</view>
			</block>
		</view>
		<view class="content" v-show="current==5">
			<view class="none" v-if="result[1].length==0">没有信息</view>
			<view class="unit" v-for="(item,index) in result[1]" :key="index" v-else>
				<view class="unit_con">
					<view class="unit_title">{{item.style}}</view>
					<view class="unit_time">{{item.logtime}}</view>
				</view>
				<view class="unit_property">
					<view class="status d">{{item.status}}</view>
					<view class="price">-{{item.balance}}元</view>
				</view>
			</view>
		</view>
	</view>
</template>
<style>
	.content{width:100%}
	.none{background: #FFFFFF;width:100%;height: 80upx;line-height: 80upx;text-align: center;font-size: 28upx;}
	.unit{width:96%;padding:10upx 2%;border-bottom: 1px solid #F1F1F1;background: #FFFFFF;display: flex;justify-content: space-between;align-items: center;}
	.noneunit{width:96%;padding:10upx 2%;border-bottom: 1px solid #F1F1F1;background: #E1E1E1;display: flex;justify-content: space-between;align-items: center;}
	
	.unit_title{height: 40upx;line-height:40upx;font-size: 28upx;font-weight: bold;}
	.unit_time{color: #999999;font-size: 24upx;line-height: 40upx;}
	.unit_property{width:15%;flex-direction: column;display: flex;justify-content: center;align-items: center;}
	.status{font-size: 24upx;}
	.price{font-size: 30upx;font-weight: bold;}
	.d{color: #3DE9C7;}
	.p{color: #999999;}
	.r{color: #ef3d19;}
	.f{color: #FFFFFF;}
	/*********************/
	page{background: #F4F4F4;}
	.container{background: #F4F4F4;}
	.top{width:100%;background-image: url("https://zhangjie.jdmuguzhid.com/static/images/yztang/bg.png");
	display: flex;justify-content: space-between;align-items: center;height: 180upx;background-repeat: no-repeat;background-size: 100% auto;}
	.balance_con{width:30%;padding:0 1.5%;display: flex;justify-content: space-between;align-items: center;height: 120upx;}
	.operate{width:31%;padding:0 1.5%;height: 120upx;display: flex;justify-content: space-between;align-items: center;flex-direction: column;}
	.used_balance{color: #FFFFFF;font-size: 28upx;display: flex;justify-content: center;align-items: center;flex-direction: column;}
	.balance{display: flex;justify-content: space-between;align-items: flex-start;height: 120upx;flex-direction: column;}
	.balance_title{display: flex;justify-content: center;align-items: center;font-size: 26upx; color: #FFFFFF;}
	.balance_title image{width:28upx;margin-right: 15upx;}
	.balance_price{line-height: 50upx;font-size: 48upx;color: #FFFFFF;font-weight: bold;}
	.balance_price text{font-size: 28upx;}
	.button{width:90%;height: 50upx;line-height: 50upx;text-align: center;font-size: 28upx;border-radius: 25upx;margin:5upx 0;}
	.g{background: #FFFFFF;color: #3de9c7;}
	.t{border:1px solid #FFFFFF;;color: #FFFFFF;}
	/***************************************/
	.nav{width:100%;height: 80upx;background-color:#FFFFFF; display: flex;align-items: center;justify-content: flex-start;flex-wrap: nowrap;}
	.nav_unit{width: 50%;height: 80upx;line-height: 80upx;  font-size: 32upx;text-align: center;}
	.font-color{color: #333333;border-bottom:2px solid #3de9c7;font-weight: bold;}
</style>
<script>
	export default {
		data() {
			return {
				current: 4,
				balance:0,
				result:[[],[]],
				start:[0,0],
				member:{},
				status:1,
				width:0,
				height:'',
				refresh_status:0,
				display:1,
				url: getApp().globalData.url,
				static:getApp().globalData.static
			}
		},
		onLoad() {
			var res = uni.getSystemInfoSync();
			this.width  = res.windowWidth;
			this.height = res.windowHeight+"px";
		},
		onShow() {
			this.initialize();
		},
		onReachBottom() {
			this.refresh_status = 1;
			this.initialize();
		},
		onReachBottom(){
			this.initialize();
		},
		methods: {
			assignment:function()
			{
				uni.navigateTo({
					url:'replace?type=2'
				})
			},
			operation:function(e)
			{
				var id = e.currentTarget.id;
				this.current = parseInt(id);
				this.initialize(this.current);
			},
			recharge:function()
			{
				uni.navigateTo({
					url:"recharge"
				})
			},
			withdrawal:function()
			{
				//#ifdef H5
					uni.navigateTo({
						url:"withdrawal"
					})
				//#endif
				//#ifdef APP-PLUS
					uni.navigateTo({
						url:"withdrawal"
					})
				//#endif
				//#ifdef MP-WEIXIN
				uni.navigateTo({
					url:"withdrawal"
				})
				// uni.showModal({
				// 	title:"操作提示",
				// 	content:"请下载谷牧之道APP，提交提现申请",
				// 	showCancel:false
				// })
				//#endif
			},
			initialize:function()
			{
				var that = this;
				var member_id = uni.getStorageSync("member_id");
				var st = this.current-4;
				// var member_id = 169136;
				uni.request({
					url: this.url+'/wechat_income_details', 
					data: {member_id:member_id,type:this.current,start:this.start[st]},
					header: {'Content-Type': 'application/json'},
					success: (res) => {
						console.log(res);
						that.member = res.data.member_result[0];
						if(res.data.status==1)
						{
							that.start[st] += 10;
							for(var k=0;k<res.data.result.length;k++)
							{
								that.result[st].push(res.data.result[k]);
							}
						}
						if(that.refresh_status==1)
						{
							that.refresh_status = 0;
							uni.stopPullDownRefresh();
						}
					}
				});
			}
		}
	}
</script>


